<?php

session_start();

require 'libs/Smarty.class.php';
require 'db.php';
require 'login.php';

$smarty = new Smarty;

if(@$_SESSION['logged']) {
	require 'work_summary.php';
	$smarty->assign('daily', $daily);
	$smarty->assign('weekly', $weekly);
	$smarty->assign('break', $break);
}

//$smarty->force_compile = true;
$smarty->debugging = false;
$smarty->caching = false;
$smarty->cache_lifetime = 120;

if(@$_POST['logout']) {
	$_SESSION['name'] = false;
	$_SESSION['logged'] = false;
	$_SESSION['uid'] = false;
	$_SESSION['admin'] = false;
}

if(@$_SESSION['logged'] && @$_SESSION['admin'] == "off") {
	$smarty->assign('logged', 1);
	$smarty->display('header.tpl');
	$smarty->display('index.tpl');
} elseif(@$_SESSION['logged'] && @$_SESSION['admin'] == "on") {
	require 'users.php';
	$smarty->assign('logged', 1);
	$smarty->display('header.tpl');
	$smarty->display('admin.tpl');
} else {
	$smarty->display('header.tpl');
	$smarty->display('login.tpl');
}

?>